package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.entity.QueryPageBean;
import com.itheima.mapper.PermissionMapper;
import com.itheima.pojo.Permission;
import com.itheima.service.PermissionService;
import org.apache.dubbo.config.annotation.Service;

import java.util.HashMap;
import java.util.Map;


@Service
//@Transactional
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper,Permission> implements PermissionService {

@Override
    public Map findPage(QueryPageBean queryPageBean){
        QueryWrapper<Permission> checkItemQueryWrapper = new QueryWrapper<>();
        String queryString = queryPageBean.getQueryString();
        checkItemQueryWrapper.like("name",queryString==null?"":queryString);
        Page<Permission> page = page(new Page<Permission>(queryPageBean.getCurrentPage(), queryPageBean.getPageSize()), checkItemQueryWrapper);
        HashMap<String, Object> map = new HashMap<>();
        map.put("total",page.getTotal());
        map.put("list",page.getRecords());
        return map;
    }

}
